   1              		.syntax unified
   2              		.cpu cortex-m3
   3              		.fpu softvfp
   4              		.eabi_attribute 20, 1
   5              		.eabi_attribute 21, 1
   6              		.eabi_attribute 23, 3
   7              		.eabi_attribute 24, 1
   8              		.eabi_attribute 25, 1
   9              		.eabi_attribute 26, 1
  10              		.eabi_attribute 30, 4
  11              		.eabi_attribute 34, 1
  12              		.eabi_attribute 18, 4
  13              		.thumb
  14              		.syntax unified
  15              		.file	"modbus.c"
  16              		.text
  17              	.Ltext0:
  18              		.cfi_sections	.debug_frame
  19              		.section	.text.master_PutString,"ax",%progbits
  20              		.align	1
  21              		.thumb
  22              		.thumb_func
  24              	master_PutString:
  25              	.LFB7:
  26              		.file 1 "modbus.c"
   1:modbus.c      **** /*
   2:modbus.c      ****  * ATENÇÃO: Recomendo a não acessar no barramento modbus não muita variáveis por vez por causa do e
   3:modbus.c      ****  */
   4:modbus.c      **** 
   5:modbus.c      **** #include "app.h"
   6:modbus.c      **** #if (LOG_MODBUS_SLAVE == pdON) || (LOG_MODBUS_MASTER == pdON)
   7:modbus.c      **** #include "stdio_uc.h"
   8:modbus.c      **** #endif
   9:modbus.c      **** 
  10:modbus.c      **** #include "uart1_irq.h"
  11:modbus.c      **** #define uartM_Init			uart1_Init
  12:modbus.c      **** #define uartM_EmptyTx 		uart1_EmptyTx
  13:modbus.c      **** #define uartM_GetChar 		uart1_GetChar
  14:modbus.c      **** #define uartM_BufferQtdRx 	uart1_BufferQtdRx
  15:modbus.c      **** #define uartM_ClearBufferRx uart1_ClearBufferRx
  16:modbus.c      **** #define uartM_WriteTx		uart1_WriteTx
  17:modbus.c      **** 
  18:modbus.c      **** #include "uart3_irq.h"
  19:modbus.c      **** #define uartS_Init			uart3_Init
  20:modbus.c      **** #define uartS_EmptyTx 		uart3_EmptyTx
  21:modbus.c      **** #define uartS_GetChar 		uart3_GetChar
  22:modbus.c      **** #define uartS_BufferQtdRx 	uart3_BufferQtdRx
  23:modbus.c      **** #define uartS_ClearBufferRx uart3_ClearBufferRx
  24:modbus.c      **** #define uartS_WriteTx		uart3_WriteTx
  25:modbus.c      **** 
  26:modbus.c      **** static int slave_SetValue(uint addr, u16 value);
  27:modbus.c      **** static int slave_PutString(u8* buffer, u16 count);
  28:modbus.c      **** static int slave_GetValue(uint addr, u16* value);
  29:modbus.c      **** static int slave_ReadRegisters(uint addrInit, u8* query, uint count);
  30:modbus.c      **** static int slave_WriteRegister(uint addr, u16 value);
  31:modbus.c      **** static int slave_WriteRegisters(uint addrInit, u8* query, uint count);
  32:modbus.c      **** 
  33:modbus.c      **** static int master_PutString(u8* buffer, u16 count);
  34:modbus.c      **** 
  35:modbus.c      **** void modbus_Init(uint id) {
  36:modbus.c      **** 	// SLAVE
  37:modbus.c      **** 	modbus_SlaveInit(id, slave_PutString, uartS_GetChar, uartS_BufferQtdRx, uartS_ClearBufferRx);
  38:modbus.c      **** 	modbus_SlaveAppendFunctions(slave_ReadRegisters, slave_WriteRegister, slave_WriteRegisters);
  39:modbus.c      **** 	rs485_ENTXS_DIR |= rs485_ENTXS;
  40:modbus.c      **** 	rs485_ENTXS_OFF = rs485_ENTXS;
  41:modbus.c      **** 	uartS_Init(BAUDRATE_RASPBERRY);
  42:modbus.c      **** 
  43:modbus.c      **** 	// MASTER
  44:modbus.c      **** 	modbus_MasterInit(master_PutString, uartM_GetChar, uartM_ClearBufferRx);
  45:modbus.c      **** 	modbus_MasterTimeout(3000);
  46:modbus.c      **** 	rs485_ENTXM_DIR |= rs485_ENTXM;
  47:modbus.c      **** 	rs485_ENTXM_OFF = rs485_ENTXM;
  48:modbus.c      **** 	uartM_Init(BAUDRATE_THERMOMETER);
  49:modbus.c      **** }
  50:modbus.c      **** 
  51:modbus.c      **** // ################################################################################################
  52:modbus.c      **** // SLAVE
  53:modbus.c      **** // ################################################################################################
  54:modbus.c      **** static int slave_PutString (u8* buffer, u16 count) {
  55:modbus.c      **** 	rs485_ENTXS_ON = rs485_ENTXS;
  56:modbus.c      **** 	int ret = uartS_WriteTx(buffer, count);
  57:modbus.c      **** 	while (!uartS_EmptyTx()); // Vamos esperar que o serial envie a mensagem
  58:modbus.c      **** 	rs485_ENTXS_OFF = rs485_ENTXS;
  59:modbus.c      **** 	return ret;
  60:modbus.c      **** }
  61:modbus.c      **** 
  62:modbus.c      **** // ------------------------------------------------------------------------------------------------
  63:modbus.c      **** // Descrição: 	Lê registradores
  64:modbus.c      **** // Parametros:	addr: Endereço do registrador
  65:modbus.c      **** //				value: Ponteiro para o retorno do valor de 16bits
  66:modbus.c      **** // Retorna:		0: Se a leitura foi feita com suscesso
  67:modbus.c      **** //				-1: O endereço do registrador não existe (modbusILLEGAL_DATA_ADDRESS (02))
  68:modbus.c      **** // ------------------------------------------------------------------------------------------------
  69:modbus.c      **** static int slave_GetValue(uint addr, u16* value) {
  70:modbus.c      **** 	int ret = 0;
  71:modbus.c      **** 	uint addrTherm = 0;
  72:modbus.c      **** 
  73:modbus.c      **** 	if ( (addr >= 0x400) && (addr < 0x1000) ) {
  74:modbus.c      **** 		addrTherm = (uint)((addr-0x400)/5); 		// Encontrar o indice do termômetro no vetor de acordo com 
  75:modbus.c      **** 		addr = (uint)((addr-0x400)%5)+0x400; 		// Conveter para o endereço base para acesso
  76:modbus.c      **** 		#if (LOG_MODBUS_SLAVE == pdON)
  77:modbus.c      ****     	plognp("    [addrTherm=0x%x] [addrbase=0x%x]"CMD_TERMINATOR, addrTherm, addr);
  78:modbus.c      ****     	#endif
  79:modbus.c      **** 	}
  80:modbus.c      **** 
  81:modbus.c      **** 	switch (addr) {
  82:modbus.c      **** 
  83:modbus.c      **** 	// -----------------------------------------------------------------------------------------------
  84:modbus.c      **** 	// ID
  85:modbus.c      **** 	case 0:	*value = (MODEL[1] << 8) | MODEL[0]; break;
  86:modbus.c      **** 	case 1:	*value = (MODEL[3] << 8) | MODEL[2]; break;
  87:modbus.c      **** 	case 2:	*value = (FIRMWARE_VERSION[2] << 8) | FIRMWARE_VERSION[0]; break;
  88:modbus.c      **** 
  89:modbus.c      **** 	// -----------------------------------------------------------------------------------------------
  90:modbus.c      **** 	// REGISTRADORES DE TRABALHO
  91:modbus.c      **** 	case 0x10: *value = nTHERMOMETER; break;
  92:modbus.c      **** 
  93:modbus.c      **** 	// Ler se há alguma ação em andamento, seja configuração de grandeza de temperatura; reset estatit
  94:modbus.c      **** 	case 0x11: *value = control.action; break;
  95:modbus.c      **** 
  96:modbus.c      **** 	// -----------------------------------------------------------------------------------------------
  97:modbus.c      **** 	// REGISTRADORES DOS TEMÔMETROS
  98:modbus.c      **** 	case 0x400: *value = control.thermometer[addrTherm].stsCom; break;
  99:modbus.c      **** 	case 0x401: *value = control.thermometer[addrTherm].sts; break;
 100:modbus.c      **** 	case 0x402: *value = control.thermometer[addrTherm].value; break;
 101:modbus.c      **** 	case 0x403: *value = control.thermometer[addrTherm].valueMin; break;
 102:modbus.c      **** 	case 0x404: *value = control.thermometer[addrTherm].valueMax; break;
 103:modbus.c      **** 
 104:modbus.c      **** 	// -----------------------------------------------------------------------------------------------
 105:modbus.c      **** 	// retorna sinalizando acesso em um registrador inválido
 106:modbus.c      **** 	default: ret = -1; break;
 107:modbus.c      **** 	}
 108:modbus.c      **** 
 109:modbus.c      **** 	return ret;
 110:modbus.c      **** }
 111:modbus.c      **** 
 112:modbus.c      **** // ------------------------------------------------------------------------------------------------
 113:modbus.c      **** // Descrição: 	Escrever nos registradores
 114:modbus.c      **** // Parametros:	addr: Endereço do registrador
 115:modbus.c      **** //				value: valor de 16bits para ser gravado no registrador
 116:modbus.c      **** // Retorna:		0: Se a gravação foi feita com suscesso
 117:modbus.c      **** //				-1: O endereço do registrador não existe (modbusILLEGAL_DATA_ADDRESS (2))
 118:modbus.c      **** // 				-2: Dado a ser gravado é inválido (modbusILLEGAL_DATA_VALUE (3))
 119:modbus.c      **** //				-3: No momento o dispositivo não pode gravar o valor, ou executar a tarefa (modbusSLAVE_DEVIC
 120:modbus.c      **** // ------------------------------------------------------------------------------------------------
 121:modbus.c      **** static int slave_SetValue(uint addr, u16 value) {
 122:modbus.c      **** 	int ret = 0;
 123:modbus.c      **** 
 124:modbus.c      **** 	switch (addr) {
 125:modbus.c      **** 
 126:modbus.c      **** 	// -----------------------------------------------------------------------------------------------
 127:modbus.c      **** 	// REGISTRADORES DO SISTEMA
 128:modbus.c      **** 
 129:modbus.c      **** 	// Especifica em que grandeza de temperatura os termômetros devem ser configurado
 130:modbus.c      **** 	//		0 = Tratamento da temperatura determinada pelo jumper do termômetro
 131:modbus.c      **** 	// 		1 = Configurar todos os termômetros a trabalhar com graus Celsius(0)
 132:modbus.c      **** 	//		2 = Configurar todos os termômetros a trabalhar com graus Fahrenheit(1)
 133:modbus.c      **** 	case 0x14:
 134:modbus.c      **** 		//if (control.action) return -3; // RERTIRADO PORQUE O PESSOAL DA UFSC NÃO ESTÁ SABENDO COMO TRAT
 135:modbus.c      **** 		if (!control.action) temp_SetType(value);
 136:modbus.c      **** 		break;
 137:modbus.c      **** 
 138:modbus.c      **** 	// Reinicia as estatísticas de temperatura
 139:modbus.c      **** 	case 0x17:
 140:modbus.c      **** 		if (control.action) return -3; // se o recurso de hardware está fazendo uma ação com os termoment
 141:modbus.c      **** 		temp_InitStatistic();
 142:modbus.c      **** 		break;
 143:modbus.c      **** 
 144:modbus.c      **** 	// -----------------------------------------------------------------------------------------------
 145:modbus.c      **** 	// retorna sinalizando acesso em um registrador inválido
 146:modbus.c      **** 	default:
 147:modbus.c      **** 		ret = -1;
 148:modbus.c      **** 	}
 149:modbus.c      **** 
 150:modbus.c      **** 	return ret;
 151:modbus.c      **** }
 152:modbus.c      **** 
 153:modbus.c      **** // ------------------------------------------------------------------------------------------------
 154:modbus.c      **** // Descrição: 	Função complementar do modbus slave para ler os registradores
 155:modbus.c      **** // Parametros:	Ver exemplos no modbus_Slave função modbus_SlaveAppendFunctions
 156:modbus.c      **** // Retorna:		A função deve retornar
 157:modbus.c      **** //					modbusNO_ERROR: Leitura feito com sucesso
 158:modbus.c      **** //					modbusILLEGAL_DATA_ADDRESS:	Endereço do registrador inexistente
 159:modbus.c      **** //					modbusILLEGAL_DATA_VALUE:	Valor inválido
 160:modbus.c      **** //					modbusSLAVE_DEVICE_FAILURE:	Um irrecuperável erro ocorreu enquanto o dispositivo estava tent
 161:modbus.c      **** //													executar a ação solicitada.
 162:modbus.c      **** // ------------------------------------------------------------------------------------------------
 163:modbus.c      **** static int slave_ReadRegisters(uint addrInit, u8* query, uint count) {
 164:modbus.c      **** 	// checa se o endereço está dentro dos limite
 165:modbus.c      **** 	if ((count == 0) || (count > 120) ) return modbusILLEGAL_DATA_ADDRESS;
 166:modbus.c      **** 
 167:modbus.c      **** 	// preenche o buffer modbus com os valores dos registradores
 168:modbus.c      **** 	int ret;
 169:modbus.c      **** 	u16 value;
 170:modbus.c      **** 	uint i; for (i=0;i<count;i++) {
 171:modbus.c      **** 		ret = slave_GetValue(addrInit+i, &value);
 172:modbus.c      **** 		if (ret == -1) return modbusILLEGAL_DATA_ADDRESS;
 173:modbus.c      **** 		else if (ret == -2) return modbusILLEGAL_DATA_VALUE;
 174:modbus.c      **** 
 175:modbus.c      **** 		query[2*i] = (u8)(value>>8);
 176:modbus.c      **** 		query[2*i+1] = (u8)(value&0xFF);
 177:modbus.c      **** 
 178:modbus.c      **** 		#if (LOG_MODBUS_SLAVE == pdON)
 179:modbus.c      ****     	plognp("MODBUS: [i=%d %d] [a=0x%x] [msb=0x%x %c] [lsb=0x%x %c]"CMD_TERMINATOR, i, count, addrI
 180:modbus.c      ****     	#endif
 181:modbus.c      **** 	}
 182:modbus.c      **** 
 183:modbus.c      **** 	return modbusNO_ERROR; // retorna sinalizando que a operação ocorreu bem
 184:modbus.c      **** }
 185:modbus.c      **** 
 186:modbus.c      **** // ------------------------------------------------------------------------------------------------
 187:modbus.c      **** // Descrição: 	Função complementar do modbus slave para escrever no registrador
 188:modbus.c      **** // Parametros:	Ver exemplos no modbus_Slave função modbus_SlaveAppendFunctions
 189:modbus.c      **** // Retorna:		A função deve retornar
 190:modbus.c      **** //					modbusNO_ERROR: Escrita feita com sucesso
 191:modbus.c      **** //					modbusILLEGAL_DATA_ADDRESS:	Endereço do registrador inexistente
 192:modbus.c      **** //					modbusILLEGAL_DATA_VALUE:	Valor para escrita é inválido
 193:modbus.c      **** //					modbusSLAVE_DEVICE_FAILURE:	Um irrecuperável erro ocorreu enquanto o dispositivo estava tent
 194:modbus.c      **** //													executar a ação solicitada.
 195:modbus.c      **** // ------------------------------------------------------------------------------------------------
 196:modbus.c      **** static int slave_WriteRegister(uint addr, u16 value) {
 197:modbus.c      **** 	int ret;
 198:modbus.c      **** 
 199:modbus.c      **** 	#if (LOG_MODBUS_SLAVE == pdON)
 200:modbus.c      ****     plognp("MODBUS: WRITE REG [a=0x%x] [val=0x%x]"CMD_TERMINATOR, addr, value);
 201:modbus.c      ****     #endif
 202:modbus.c      **** 
 203:modbus.c      **** 	ret = slave_SetValue(addr, value);
 204:modbus.c      **** 	if (ret == -1) ret = modbusILLEGAL_DATA_ADDRESS;
 205:modbus.c      **** 	else if (ret == -2) ret = modbusILLEGAL_DATA_VALUE;
 206:modbus.c      **** 	else if (ret == -3) ret = modbusSLAVE_DEVICE_FAILURE;
 207:modbus.c      **** 	else ret = modbusNO_ERROR; // retorna sinalizando que a operação ocorreu bem
 208:modbus.c      **** 
 209:modbus.c      ****     return ret;
 210:modbus.c      **** }
 211:modbus.c      **** 
 212:modbus.c      **** // ------------------------------------------------------------------------------------------------
 213:modbus.c      **** // Descrição: 	Função complementar do modbus slave para escrever nos registradores
 214:modbus.c      **** // Parametros:	Ver exemplos no modbus_Slave função modbus_SlaveAppendFunctions
 215:modbus.c      **** // Retorna:		A função deve retornar
 216:modbus.c      **** //					modbusNO_ERROR: Escrita feita com sucesso
 217:modbus.c      **** //					modbusILLEGAL_DATA_ADDRESS:	Endereço do registrador inexistente
 218:modbus.c      **** //					modbusILLEGAL_DATA_VALUE:	Valor para escrita é inválido
 219:modbus.c      **** //					modbusSLAVE_DEVICE_FAILURE:	Um irrecuperável erro ocorreu enquanto o dispositivo estava tent
 220:modbus.c      **** //													executar a ação solicitada.
 221:modbus.c      **** // ------------------------------------------------------------------------------------------------
 222:modbus.c      **** static int slave_WriteRegisters(uint addrInit, u8* query, uint count) {
 223:modbus.c      **** 	// checa se o endereço está dentro dos limite
 224:modbus.c      **** 	if ((count == 0) || (count > 120) ) return modbusILLEGAL_DATA_ADDRESS;
 225:modbus.c      **** 
 226:modbus.c      **** 	// salva os valores recebidos nos seus respectivos registradores
 227:modbus.c      **** 	int ret;
 228:modbus.c      **** 	uint i; for (i=0;i<count;i++) {
 229:modbus.c      **** 		ret = slave_SetValue(addrInit+i, (((u8)query[2*i]<<8) | query[2*i+1]));
 230:modbus.c      **** 		if (ret == -1) return modbusILLEGAL_DATA_ADDRESS;
 231:modbus.c      **** 		else if (ret == -2) return modbusILLEGAL_DATA_VALUE;
 232:modbus.c      **** 		else if (ret == -3) return modbusSLAVE_DEVICE_FAILURE;
 233:modbus.c      **** 
 234:modbus.c      **** 		#if (LOG_MODBUS_SLAVE == pdON)
 235:modbus.c      ****     	plognp("MODBUS: [a=0x%x] [v=0x%x]"CMD_TERMINATOR, addrInit, (((u8)query[2*i]<<8) | query[2*i+1
 236:modbus.c      ****     	#endif
 237:modbus.c      **** 	}
 238:modbus.c      **** 
 239:modbus.c      **** 	return modbusNO_ERROR; // retorna sinalizando que a operação ocorreu bem
 240:modbus.c      **** }
 241:modbus.c      **** 
 242:modbus.c      **** 
 243:modbus.c      **** // ################################################################################################
 244:modbus.c      **** // MASTER
 245:modbus.c      **** // ################################################################################################
 246:modbus.c      **** static int master_PutString(u8* buffer, u16 count) {
  27              		.loc 1 246 0
  28              		.cfi_startproc
  29              		@ args = 0, pretend = 0, frame = 0
  30              		@ frame_needed = 0, uses_anonymous_args = 0
  31              	.LVL0:
 247:modbus.c      **** 	rs485_ENTXM_ON = rs485_ENTXM;
  32              		.loc 1 247 0
  33 0000 084B     		ldr	r3, .L6
  34 0002 4FF40032 		mov	r2, #131072
 246:modbus.c      **** 	rs485_ENTXM_ON = rs485_ENTXM;
  35              		.loc 1 246 0
  36 0006 10B5     		push	{r4, lr}
  37              	.LCFI0:
  38              		.cfi_def_cfa_offset 8
  39              		.cfi_offset 4, -8
  40              		.cfi_offset 14, -4
  41              		.loc 1 247 0
  42 0008 1A60     		str	r2, [r3]
 248:modbus.c      **** 	int ret = uartM_WriteTx(buffer, count);
  43              		.loc 1 248 0
  44 000a FFF7FEFF 		bl	uart1_WriteTx
  45              	.LVL1:
  46 000e 0446     		mov	r4, r0
  47              	.LVL2:
  48              	.L2:
 249:modbus.c      **** 	while (!uartM_EmptyTx()); // Vamos esperar que o serial envie a mensagem
  49              		.loc 1 249 0 discriminator 1
  50 0010 FFF7FEFF 		bl	uart1_EmptyTx
  51              	.LVL3:
  52 0014 0028     		cmp	r0, #0
  53 0016 FBD0     		beq	.L2
 250:modbus.c      **** 	rs485_ENTXM_OFF = rs485_ENTXM;
  54              		.loc 1 250 0
  55 0018 034B     		ldr	r3, .L6+4
  56 001a 4FF40032 		mov	r2, #131072
  57 001e 1A60     		str	r2, [r3]
 251:modbus.c      **** 	return ret;
 252:modbus.c      **** }
  58              		.loc 1 252 0
  59 0020 2046     		mov	r0, r4
  60 0022 10BD     		pop	{r4, pc}
  61              	.LVL4:
  62              	.L7:
  63              		.align	2
  64              	.L6:
  65 0024 18C00920 		.word	537509912
  66 0028 1CC00920 		.word	537509916
  67              		.cfi_endproc
  68              	.LFE7:
  70              		.section	.text.slave_PutString,"ax",%progbits
  71              		.align	1
  72              		.thumb
  73              		.thumb_func
  75              	slave_PutString:
  76              	.LFB1:
  54:modbus.c      **** 	rs485_ENTXS_ON = rs485_ENTXS;
  77              		.loc 1 54 0
  78              		.cfi_startproc
  79              		@ args = 0, pretend = 0, frame = 0
  80              		@ frame_needed = 0, uses_anonymous_args = 0
  81              	.LVL5:
  55:modbus.c      **** 	int ret = uartS_WriteTx(buffer, count);
  82              		.loc 1 55 0
  83 0000 084B     		ldr	r3, .L12
  84 0002 4FF08042 		mov	r2, #1073741824
  54:modbus.c      **** 	rs485_ENTXS_ON = rs485_ENTXS;
  85              		.loc 1 54 0
  86 0006 10B5     		push	{r4, lr}
  87              	.LCFI1:
  88              		.cfi_def_cfa_offset 8
  89              		.cfi_offset 4, -8
  90              		.cfi_offset 14, -4
  55:modbus.c      **** 	int ret = uartS_WriteTx(buffer, count);
  91              		.loc 1 55 0
  92 0008 1A60     		str	r2, [r3]
  56:modbus.c      **** 	while (!uartS_EmptyTx()); // Vamos esperar que o serial envie a mensagem
  93              		.loc 1 56 0
  94 000a FFF7FEFF 		bl	uart3_WriteTx
  95              	.LVL6:
  96 000e 0446     		mov	r4, r0
  97              	.LVL7:
  98              	.L9:
  57:modbus.c      **** 	rs485_ENTXS_OFF = rs485_ENTXS;
  99              		.loc 1 57 0 discriminator 1
 100 0010 FFF7FEFF 		bl	uart3_EmptyTx
 101              	.LVL8:
 102 0014 0028     		cmp	r0, #0
 103 0016 FBD0     		beq	.L9
  58:modbus.c      **** 	return ret;
 104              		.loc 1 58 0
 105 0018 034B     		ldr	r3, .L12+4
 106 001a 4FF08042 		mov	r2, #1073741824
 107 001e 1A60     		str	r2, [r3]
  60:modbus.c      **** 
 108              		.loc 1 60 0
 109 0020 2046     		mov	r0, r4
 110 0022 10BD     		pop	{r4, pc}
 111              	.LVL9:
 112              	.L13:
 113              		.align	2
 114              	.L12:
 115 0024 18C00920 		.word	537509912
 116 0028 1CC00920 		.word	537509916
 117              		.cfi_endproc
 118              	.LFE1:
 120              		.section	.text.slave_ReadRegisters,"ax",%progbits
 121              		.align	1
 122              		.thumb
 123              		.thumb_func
 125              	slave_ReadRegisters:
 126              	.LFB4:
 163:modbus.c      **** 	// checa se o endereço está dentro dos limite
 127              		.loc 1 163 0
 128              		.cfi_startproc
 129              		@ args = 0, pretend = 0, frame = 0
 130              		@ frame_needed = 0, uses_anonymous_args = 0
 131              	.LVL10:
 165:modbus.c      **** 
 132              		.loc 1 165 0
 133 0000 531E     		subs	r3, r2, #1
 134 0002 772B     		cmp	r3, #119
 163:modbus.c      **** 	// checa se o endereço está dentro dos limite
 135              		.loc 1 163 0
 136 0004 2DE9F043 		push	{r4, r5, r6, r7, r8, r9, lr}
 137              	.LCFI2:
 138              		.cfi_def_cfa_offset 28
 139              		.cfi_offset 4, -28
 140              		.cfi_offset 5, -24
 141              		.cfi_offset 6, -20
 142              		.cfi_offset 7, -16
 143              		.cfi_offset 8, -12
 144              		.cfi_offset 9, -8
 145              		.cfi_offset 14, -4
 165:modbus.c      **** 
 146              		.loc 1 165 0
 147 0008 54D8     		bhi	.L32
 148              	.LBB6:
 149              	.LBB7:
 150              	.LBB8:
 151              	.LBB9:
  81:modbus.c      **** 
 152              		.loc 1 81 0
 153 000a 40F20247 		movw	r7, #1026
 154 000e 40F2034E 		movw	lr, #1027
 155 0012 40F2044C 		movw	ip, #1028
 156 0016 40F20148 		movw	r8, #1025
  94:modbus.c      **** 
 157              		.loc 1 94 0
 158 001a 314C     		ldr	r4, .L36
 159 001c A0F58060 		sub	r0, r0, #1024
 160              	.LVL11:
 161 0020 01EB4202 		add	r2, r1, r2, lsl #1
 162              	.LVL12:
  74:modbus.c      **** 		addr = (uint)((addr-0x400)%5)+0x400; 		// Conveter para o endereço base para acesso
 163              		.loc 1 74 0
 164 0024 0526     		movs	r6, #5
 100:modbus.c      **** 	case 0x403: *value = control.thermometer[addrTherm].valueMin; break;
 165              		.loc 1 100 0
 166 0026 1C25     		movs	r5, #28
 167              	.LVL13:
 168              	.L29:
  73:modbus.c      **** 		addrTherm = (uint)((addr-0x400)/5); 		// Encontrar o indice do termômetro no vetor de acordo com 
 169              		.loc 1 73 0
 170 0028 B0F5406F 		cmp	r0, #3072
  74:modbus.c      **** 		addr = (uint)((addr-0x400)%5)+0x400; 		// Conveter para o endereço base para acesso
 171              		.loc 1 74 0
 172 002c 38BF     		it	cc
 173 002e B0FBF6F3 		udivcc	r3, r0, r6
 174 0032 00F58069 		add	r9, r0, #1024
 175              	.LVL14:
  75:modbus.c      **** 		#if (LOG_MODBUS_SLAVE == pdON)
 176              		.loc 1 75 0
 177 0036 3DBF     		ittte	cc
 178 0038 03EB8309 		addcc	r9, r3, r3, lsl #2
 179              	.LVL15:
 180 003c C9EB0009 		rsbcc	r9, r9, r0
 181 0040 09F58069 		addcc	r9, r9, #1024
 182              	.LVL16:
  71:modbus.c      **** 
 183              		.loc 1 71 0
 184 0044 0023     		movcs	r3, #0
 185              	.LVL17:
  81:modbus.c      **** 
 186              		.loc 1 81 0
 187 0046 B9F1110F 		cmp	r9, #17
 188 004a 23D0     		beq	.L17
 189 004c 0BD8     		bhi	.L18
 190 004e B9F1010F 		cmp	r9, #1
 191 0052 1CD0     		beq	.L19
 192 0054 31D3     		bcc	.L20
 193 0056 B9F1020F 		cmp	r9, #2
 194 005a 31D0     		beq	.L33
 195 005c B9F1100F 		cmp	r9, #16
 196 0060 28D1     		bne	.L32
 197              	.LVL18:
  91:modbus.c      **** 
 198              		.loc 1 91 0
 199 0062 0123     		movs	r3, #1
 200              	.LVL19:
 201 0064 2EE0     		b	.L21
 202              	.LVL20:
 203              	.L18:
  81:modbus.c      **** 
 204              		.loc 1 81 0
 205 0066 B945     		cmp	r9, r7
 206 0068 1CD0     		beq	.L23
 207 006a 08D8     		bhi	.L24
 208 006c B9F5806F 		cmp	r9, #1024
 209 0070 14D0     		beq	.L25
 210 0072 C145     		cmp	r9, r8
 211 0074 1ED1     		bne	.L32
  99:modbus.c      **** 	case 0x402: *value = control.thermometer[addrTherm].value; break;
 212              		.loc 1 99 0
 213 0076 05FB0343 		mla	r3, r5, r3, r4
 214              	.LVL21:
 215 007a 9B8C     		ldrh	r3, [r3, #36]
 216              	.LVL22:
 217 007c 22E0     		b	.L21
 218              	.LVL23:
 219              	.L24:
  81:modbus.c      **** 
 220              		.loc 1 81 0
 221 007e F145     		cmp	r9, lr
 222 0080 14D0     		beq	.L27
 223 0082 E145     		cmp	r9, ip
 224 0084 16D1     		bne	.L32
 102:modbus.c      **** 
 225              		.loc 1 102 0
 226 0086 05FB0343 		mla	r3, r5, r3, r4
 227              	.LVL24:
 228 008a 1B8E     		ldrh	r3, [r3, #48]
 229              	.LVL25:
 230 008c 1AE0     		b	.L21
 231              	.LVL26:
 232              	.L19:
  86:modbus.c      **** 	case 2:	*value = (FIRMWARE_VERSION[2] << 8) | FIRMWARE_VERSION[0]; break;
 233              		.loc 1 86 0
 234 008e 43F23013 		movw	r3, #12592
 235              	.LVL27:
 236 0092 17E0     		b	.L21
 237              	.LVL28:
 238              	.L17:
  94:modbus.c      **** 
 239              		.loc 1 94 0
 240 0094 2378     		ldrb	r3, [r4]	@ zero_extendqisi2
 241              	.LVL29:
 242 0096 03F00103 		and	r3, r3, #1
 243              	.LVL30:
 244 009a 13E0     		b	.L21
 245              	.LVL31:
 246              	.L25:
  98:modbus.c      **** 	case 0x401: *value = control.thermometer[addrTherm].sts; break;
 247              		.loc 1 98 0
 248 009c 05FB0343 		mla	r3, r5, r3, r4
 249              	.LVL32:
 250 00a0 1B8C     		ldrh	r3, [r3, #32]
 251              	.LVL33:
 252 00a2 0FE0     		b	.L21
 253              	.LVL34:
 254              	.L23:
 100:modbus.c      **** 	case 0x403: *value = control.thermometer[addrTherm].valueMin; break;
 255              		.loc 1 100 0
 256 00a4 05FB0343 		mla	r3, r5, r3, r4
 257              	.LVL35:
 258 00a8 1B8D     		ldrh	r3, [r3, #40]
 259              	.LVL36:
 260 00aa 0BE0     		b	.L21
 261              	.LVL37:
 262              	.L27:
 101:modbus.c      **** 	case 0x404: *value = control.thermometer[addrTherm].valueMax; break;
 263              		.loc 1 101 0
 264 00ac 05FB0343 		mla	r3, r5, r3, r4
 265              	.LVL38:
 266 00b0 9B8D     		ldrh	r3, [r3, #44]
 267              	.LVL39:
 268 00b2 07E0     		b	.L21
 269              	.LVL40:
 270              	.L32:
 271              	.LBE9:
 272              	.LBE8:
 172:modbus.c      **** 		else if (ret == -2) return modbusILLEGAL_DATA_VALUE;
 273              		.loc 1 172 0
 274 00b4 0220     		movs	r0, #2
 275 00b6 BDE8F083 		pop	{r4, r5, r6, r7, r8, r9, pc}
 276              	.LVL41:
 277              	.L20:
 278              	.LBB11:
 279              	.LBB10:
  85:modbus.c      **** 	case 1:	*value = (MODEL[3] << 8) | MODEL[2]; break;
 280              		.loc 1 85 0
 281 00ba 47F26823 		movw	r3, #29288
 282              	.LVL42:
 283 00be 01E0     		b	.L21
 284              	.LVL43:
 285              	.L33:
  87:modbus.c      **** 
 286              		.loc 1 87 0
 287 00c0 43F23113 		movw	r3, #12593
 288              	.LVL44:
 289              	.L21:
 290              	.LBE10:
 291              	.LBE11:
 175:modbus.c      **** 		query[2*i+1] = (u8)(value&0xFF);
 292              		.loc 1 175 0
 293 00c4 4FEA1329 		lsr	r9, r3, #8
 294 00c8 81F80090 		strb	r9, [r1]
 176:modbus.c      **** 
 295              		.loc 1 176 0
 296 00cc 4B70     		strb	r3, [r1, #1]
 297              	.LVL45:
 298 00ce 0231     		adds	r1, r1, #2
 170:modbus.c      **** 		ret = slave_GetValue(addrInit+i, &value);
 299              		.loc 1 170 0
 300 00d0 8A42     		cmp	r2, r1
 301 00d2 00F10100 		add	r0, r0, #1
 302              	.LVL46:
 303 00d6 A7D1     		bne	.L29
 183:modbus.c      **** }
 304              		.loc 1 183 0
 305 00d8 0020     		movs	r0, #0
 306              	.LVL47:
 307              	.LBE7:
 308              	.LBE6:
 184:modbus.c      **** 
 309              		.loc 1 184 0
 310 00da BDE8F083 		pop	{r4, r5, r6, r7, r8, r9, pc}
 311              	.L37:
 312 00de 00BF     		.align	2
 313              	.L36:
 314 00e0 00000000 		.word	control
 315              		.cfi_endproc
 316              	.LFE4:
 318              		.section	.text.slave_SetValue,"ax",%progbits
 319              		.align	1
 320              		.thumb
 321              		.thumb_func
 323              	slave_SetValue:
 324              	.LFB3:
 121:modbus.c      **** 	int ret = 0;
 325              		.loc 1 121 0
 326              		.cfi_startproc
 327              		@ args = 0, pretend = 0, frame = 0
 328              		@ frame_needed = 0, uses_anonymous_args = 0
 329              	.LVL48:
 124:modbus.c      **** 
 330              		.loc 1 124 0
 331 0000 1428     		cmp	r0, #20
 121:modbus.c      **** 	int ret = 0;
 332              		.loc 1 121 0
 333 0002 10B5     		push	{r4, lr}
 334              	.LCFI3:
 335              		.cfi_def_cfa_offset 8
 336              		.cfi_offset 4, -8
 337              		.cfi_offset 14, -4
 124:modbus.c      **** 
 338              		.loc 1 124 0
 339 0004 02D0     		beq	.L40
 340 0006 1728     		cmp	r0, #23
 341 0008 09D0     		beq	.L41
 342 000a 11E0     		b	.L47
 343              	.L40:
 344              	.LVL49:
 345              	.LBB14:
 346              	.LBB15:
 135:modbus.c      **** 		break;
 347              		.loc 1 135 0
 348 000c 0C4B     		ldr	r3, .L48
 349 000e 1B78     		ldrb	r3, [r3]	@ zero_extendqisi2
 350 0010 13F00104 		ands	r4, r3, #1
 351 0014 0FD1     		bne	.L43
 352 0016 0846     		mov	r0, r1
 353              	.LVL50:
 354 0018 FFF7FEFF 		bl	temp_SetType
 355              	.LVL51:
 356 001c 06E0     		b	.L46
 357              	.LVL52:
 358              	.L41:
 359              	.LBE15:
 360              	.LBE14:
 140:modbus.c      **** 		temp_InitStatistic();
 361              		.loc 1 140 0
 362 001e 084B     		ldr	r3, .L48
 363 0020 1878     		ldrb	r0, [r3]	@ zero_extendqisi2
 364              	.LVL53:
 365 0022 10F00104 		ands	r4, r0, #1
 366 0026 08D1     		bne	.L44
 141:modbus.c      **** 		break;
 367              		.loc 1 141 0
 368 0028 FFF7FEFF 		bl	temp_InitStatistic
 369              	.LVL54:
 370              	.L46:
 122:modbus.c      **** 
 371              		.loc 1 122 0
 372 002c 2046     		mov	r0, r4
 142:modbus.c      **** 
 373              		.loc 1 142 0
 374 002e 10BD     		pop	{r4, pc}
 375              	.LVL55:
 376              	.L47:
 147:modbus.c      **** 	}
 377              		.loc 1 147 0
 378 0030 4FF0FF30 		mov	r0, #-1
 379              	.LVL56:
 380 0034 10BD     		pop	{r4, pc}
 381              	.LVL57:
 382              	.L43:
 383              	.LBB17:
 384              	.LBB16:
 135:modbus.c      **** 		break;
 385              		.loc 1 135 0
 386 0036 0020     		movs	r0, #0
 387              	.LVL58:
 388 0038 10BD     		pop	{r4, pc}
 389              	.LVL59:
 390              	.L44:
 391              	.LBE16:
 392              	.LBE17:
 140:modbus.c      **** 		temp_InitStatistic();
 393              		.loc 1 140 0
 394 003a 6FF00200 		mvn	r0, #2
 151:modbus.c      **** 
 395              		.loc 1 151 0
 396 003e 10BD     		pop	{r4, pc}
 397              	.L49:
 398              		.align	2
 399              	.L48:
 400 0040 00000000 		.word	control
 401              		.cfi_endproc
 402              	.LFE3:
 404              		.section	.text.slave_WriteRegister,"ax",%progbits
 405              		.align	1
 406              		.thumb
 407              		.thumb_func
 409              	slave_WriteRegister:
 410              	.LFB5:
 196:modbus.c      **** 	int ret;
 411              		.loc 1 196 0
 412              		.cfi_startproc
 413              		@ args = 0, pretend = 0, frame = 0
 414              		@ frame_needed = 0, uses_anonymous_args = 0
 415              	.LVL60:
 416 0000 08B5     		push	{r3, lr}
 417              	.LCFI4:
 418              		.cfi_def_cfa_offset 8
 419              		.cfi_offset 3, -8
 420              		.cfi_offset 14, -4
 203:modbus.c      **** 	if (ret == -1) ret = modbusILLEGAL_DATA_ADDRESS;
 421              		.loc 1 203 0
 422 0002 FFF7FEFF 		bl	slave_SetValue
 423              	.LVL61:
 204:modbus.c      **** 	else if (ret == -2) ret = modbusILLEGAL_DATA_VALUE;
 424              		.loc 1 204 0
 425 0006 411C     		adds	r1, r0, #1
 426 0008 06D0     		beq	.L52
 205:modbus.c      **** 	else if (ret == -3) ret = modbusSLAVE_DEVICE_FAILURE;
 427              		.loc 1 205 0
 428 000a 821C     		adds	r2, r0, #2
 429 000c 06D0     		beq	.L53
 206:modbus.c      **** 	else ret = modbusNO_ERROR; // retorna sinalizando que a operação ocorreu bem
 430              		.loc 1 206 0
 431 000e C31C     		adds	r3, r0, #3
 207:modbus.c      **** 
 432              		.loc 1 207 0
 433 0010 0CBF     		ite	eq
 434 0012 0420     		moveq	r0, #4
 435              	.LVL62:
 436 0014 0020     		movne	r0, #0
 437 0016 08BD     		pop	{r3, pc}
 438              	.LVL63:
 439              	.L52:
 204:modbus.c      **** 	else if (ret == -2) ret = modbusILLEGAL_DATA_VALUE;
 440              		.loc 1 204 0
 441 0018 0220     		movs	r0, #2
 442              	.LVL64:
 443 001a 08BD     		pop	{r3, pc}
 444              	.LVL65:
 445              	.L53:
 205:modbus.c      **** 	else if (ret == -3) ret = modbusSLAVE_DEVICE_FAILURE;
 446              		.loc 1 205 0
 447 001c 0320     		movs	r0, #3
 448              	.LVL66:
 210:modbus.c      **** 
 449              		.loc 1 210 0
 450 001e 08BD     		pop	{r3, pc}
 451              		.cfi_endproc
 452              	.LFE5:
 454              		.section	.text.slave_WriteRegisters,"ax",%progbits
 455              		.align	1
 456              		.thumb
 457              		.thumb_func
 459              	slave_WriteRegisters:
 460              	.LFB6:
 222:modbus.c      **** 	// checa se o endereço está dentro dos limite
 461              		.loc 1 222 0
 462              		.cfi_startproc
 463              		@ args = 0, pretend = 0, frame = 0
 464              		@ frame_needed = 0, uses_anonymous_args = 0
 465              	.LVL67:
 466 0000 F8B5     		push	{r3, r4, r5, r6, r7, lr}
 467              	.LCFI5:
 468              		.cfi_def_cfa_offset 24
 469              		.cfi_offset 3, -24
 470              		.cfi_offset 4, -20
 471              		.cfi_offset 5, -16
 472              		.cfi_offset 6, -12
 473              		.cfi_offset 7, -8
 474              		.cfi_offset 14, -4
 224:modbus.c      **** 
 475              		.loc 1 224 0
 476 0002 531E     		subs	r3, r2, #1
 477 0004 772B     		cmp	r3, #119
 478 0006 01D9     		bls	.L56
 479              	.LVL68:
 480              	.L58:
 481 0008 0220     		movs	r0, #2
 482 000a F8BD     		pop	{r3, r4, r5, r6, r7, pc}
 483              	.LVL69:
 484              	.L56:
 485 000c 0D46     		mov	r5, r1
 486 000e 0446     		mov	r4, r0
 487 0010 1618     		adds	r6, r2, r0
 488 0012 A1EB4007 		sub	r7, r1, r0, lsl #1
 489              	.LVL70:
 490              	.L59:
 491              	.LBB20:
 492              	.LBB21:
 229:modbus.c      **** 		if (ret == -1) return modbusILLEGAL_DATA_ADDRESS;
 493              		.loc 1 229 0
 494 0016 17F81410 		ldrb	r1, [r7, r4, lsl #1]	@ zero_extendqisi2
 495 001a 6B78     		ldrb	r3, [r5, #1]	@ zero_extendqisi2
 496 001c 2046     		mov	r0, r4
 497 001e 43EA0121 		orr	r1, r3, r1, lsl #8
 498 0022 FFF7FEFF 		bl	slave_SetValue
 499              	.LVL71:
 230:modbus.c      **** 		else if (ret == -2) return modbusILLEGAL_DATA_VALUE;
 500              		.loc 1 230 0
 501 0026 421C     		adds	r2, r0, #1
 502 0028 EED0     		beq	.L58
 231:modbus.c      **** 		else if (ret == -3) return modbusSLAVE_DEVICE_FAILURE;
 503              		.loc 1 231 0
 504 002a 831C     		adds	r3, r0, #2
 505 002c 08D0     		beq	.L60
 232:modbus.c      **** 
 506              		.loc 1 232 0
 507 002e 0330     		adds	r0, r0, #3
 508              	.LVL72:
 509 0030 08D0     		beq	.L61
 510              	.LVL73:
 511 0032 0134     		adds	r4, r4, #1
 512              	.LVL74:
 228:modbus.c      **** 		ret = slave_SetValue(addrInit+i, (((u8)query[2*i]<<8) | query[2*i+1]));
 513              		.loc 1 228 0
 514 0034 A642     		cmp	r6, r4
 515 0036 05F10205 		add	r5, r5, #2
 516 003a ECD1     		bne	.L59
 239:modbus.c      **** }
 517              		.loc 1 239 0
 518 003c 0020     		movs	r0, #0
 519              	.LVL75:
 520 003e F8BD     		pop	{r3, r4, r5, r6, r7, pc}
 521              	.LVL76:
 522              	.L60:
 231:modbus.c      **** 		else if (ret == -3) return modbusSLAVE_DEVICE_FAILURE;
 523              		.loc 1 231 0
 524 0040 0320     		movs	r0, #3
 525              	.LVL77:
 526 0042 F8BD     		pop	{r3, r4, r5, r6, r7, pc}
 527              	.LVL78:
 528              	.L61:
 232:modbus.c      **** 
 529              		.loc 1 232 0
 530 0044 0420     		movs	r0, #4
 531              	.LBE21:
 532              	.LBE20:
 240:modbus.c      **** 
 533              		.loc 1 240 0
 534 0046 F8BD     		pop	{r3, r4, r5, r6, r7, pc}
 535              		.cfi_endproc
 536              	.LFE6:
 538              		.section	.text.modbus_Init,"ax",%progbits
 539              		.align	1
 540              		.global	modbus_Init
 541              		.thumb
 542              		.thumb_func
 544              	modbus_Init:
 545              	.LFB0:
  35:modbus.c      **** 	// SLAVE
 546              		.loc 1 35 0
 547              		.cfi_startproc
 548              		@ args = 0, pretend = 0, frame = 0
 549              		@ frame_needed = 0, uses_anonymous_args = 0
 550              	.LVL79:
 551 0000 37B5     		push	{r0, r1, r2, r4, r5, lr}
 552              	.LCFI6:
 553              		.cfi_def_cfa_offset 24
 554              		.cfi_offset 4, -12
 555              		.cfi_offset 5, -8
 556              		.cfi_offset 14, -4
  37:modbus.c      **** 	modbus_SlaveAppendFunctions(slave_ReadRegisters, slave_WriteRegister, slave_WriteRegisters);
 557              		.loc 1 37 0
 558 0002 184B     		ldr	r3, .L67
  39:modbus.c      **** 	rs485_ENTXS_OFF = rs485_ENTXS;
 559              		.loc 1 39 0
 560 0004 184C     		ldr	r4, .L67+4
  37:modbus.c      **** 	modbus_SlaveAppendFunctions(slave_ReadRegisters, slave_WriteRegister, slave_WriteRegisters);
 561              		.loc 1 37 0
 562 0006 0093     		str	r3, [sp]
 563 0008 184A     		ldr	r2, .L67+8
 564 000a 194B     		ldr	r3, .L67+12
 565 000c 1949     		ldr	r1, .L67+16
 566 000e FFF7FEFF 		bl	modbus_SlaveInit
 567              	.LVL80:
  38:modbus.c      **** 	rs485_ENTXS_DIR |= rs485_ENTXS;
 568              		.loc 1 38 0
 569 0012 194A     		ldr	r2, .L67+20
 570 0014 1949     		ldr	r1, .L67+24
 571 0016 1A48     		ldr	r0, .L67+28
 572 0018 FFF7FEFF 		bl	modbus_SlaveAppendFunctions
 573              	.LVL81:
  39:modbus.c      **** 	rs485_ENTXS_OFF = rs485_ENTXS;
 574              		.loc 1 39 0
 575 001c 2368     		ldr	r3, [r4]
  40:modbus.c      **** 	uartS_Init(BAUDRATE_RASPBERRY);
 576              		.loc 1 40 0
 577 001e 194D     		ldr	r5, .L67+32
  39:modbus.c      **** 	rs485_ENTXS_OFF = rs485_ENTXS;
 578              		.loc 1 39 0
 579 0020 43F08043 		orr	r3, r3, #1073741824
 580 0024 2360     		str	r3, [r4]
  40:modbus.c      **** 	uartS_Init(BAUDRATE_RASPBERRY);
 581              		.loc 1 40 0
 582 0026 4FF08043 		mov	r3, #1073741824
 583 002a 2B60     		str	r3, [r5]
  41:modbus.c      **** 
 584              		.loc 1 41 0
 585 002c 4FF46140 		mov	r0, #57600
 586 0030 FFF7FEFF 		bl	uart3_Init
 587              	.LVL82:
  44:modbus.c      **** 	modbus_MasterTimeout(3000);
 588              		.loc 1 44 0
 589 0034 144A     		ldr	r2, .L67+36
 590 0036 1549     		ldr	r1, .L67+40
 591 0038 1548     		ldr	r0, .L67+44
 592 003a FFF7FEFF 		bl	modbus_MasterInit
 593              	.LVL83:
  45:modbus.c      **** 	rs485_ENTXM_DIR |= rs485_ENTXM;
 594              		.loc 1 45 0
 595 003e 40F6B830 		movw	r0, #3000
 596 0042 FFF7FEFF 		bl	modbus_MasterTimeout
 597              	.LVL84:
  46:modbus.c      **** 	rs485_ENTXM_OFF = rs485_ENTXM;
 598              		.loc 1 46 0
 599 0046 2368     		ldr	r3, [r4]
  48:modbus.c      **** }
 600              		.loc 1 48 0
 601 0048 4FF46140 		mov	r0, #57600
  46:modbus.c      **** 	rs485_ENTXM_OFF = rs485_ENTXM;
 602              		.loc 1 46 0
 603 004c 43F40033 		orr	r3, r3, #131072
 604 0050 2360     		str	r3, [r4]
  47:modbus.c      **** 	uartM_Init(BAUDRATE_THERMOMETER);
 605              		.loc 1 47 0
 606 0052 4FF40033 		mov	r3, #131072
 607 0056 2B60     		str	r3, [r5]
  49:modbus.c      **** 
 608              		.loc 1 49 0
 609 0058 03B0     		add	sp, sp, #12
 610              	.LCFI7:
 611              		.cfi_def_cfa_offset 12
 612              		@ sp needed
 613 005a BDE83040 		pop	{r4, r5, lr}
 614              	.LCFI8:
 615              		.cfi_restore 14
 616              		.cfi_restore 5
 617              		.cfi_restore 4
 618              		.cfi_def_cfa_offset 0
  48:modbus.c      **** }
 619              		.loc 1 48 0
 620 005e FFF7FEBF 		b	uart1_Init
 621              	.LVL85:
 622              	.L68:
 623 0062 00BF     		.align	2
 624              	.L67:
 625 0064 00000000 		.word	uart3_ClearBufferRx
 626 0068 00C00920 		.word	537509888
 627 006c 00000000 		.word	uart3_GetChar
 628 0070 00000000 		.word	uart3_BufferQtdRx
 629 0074 00000000 		.word	slave_PutString
 630 0078 00000000 		.word	slave_WriteRegisters
 631 007c 00000000 		.word	slave_WriteRegister
 632 0080 00000000 		.word	slave_ReadRegisters
 633 0084 1CC00920 		.word	537509916
 634 0088 00000000 		.word	uart1_ClearBufferRx
 635 008c 00000000 		.word	uart1_GetChar
 636 0090 00000000 		.word	master_PutString
 637              		.cfi_endproc
 638              	.LFE0:
 640              		.section	.text.modbus_SendCommand,"ax",%progbits
 641              		.align	1
 642              		.global	modbus_SendCommand
 643              		.thumb
 644              		.thumb_func
 646              	modbus_SendCommand:
 647              	.LFB8:
 253:modbus.c      **** 
 254:modbus.c      **** static int waitResponse = pdFALSE;
 255:modbus.c      **** static tCommand cmd;
 256:modbus.c      **** static u16 regs[120]; // registrador de trabalho para troca de dados com os termômetros
 257:modbus.c      **** 
 258:modbus.c      **** // Para gravação os valores dos registradores devem já estar preenchidos
 259:modbus.c      **** // Após uma leitura os registradores estarão atualizados
 260:modbus.c      **** 
 261:modbus.c      **** // Envia um comando para o escravo, nesta mesma função é feito o procedimento de erro de envio
 262:modbus.c      **** // Uma vez enviado o comando com sucesso, capturar resposta no modbus_Process
 263:modbus.c      **** //	BUSY: Ficar na espera da resposta
 264:modbus.c      **** //  ERROR: Notificar um erro, e tomar o procedimento cabível
 265:modbus.c      **** //  OK para escrita: Fazer nada, pois os valores dos registradores foram salvos no escravo com suce
 266:modbus.c      **** //	OK para Leitura: Capturar os valores dos registradores lidos do escravo
 267:modbus.c      **** // Parâmetros:
 268:modbus.c      **** // 		slaveID. Endereço do escravo a ser acessado
 269:modbus.c      **** // 		c: Tipo de comando para ser enviado ao escravo
 270:modbus.c      **** typedef enum {readREGS, writeREG, writeREGS} tcmd;
 271:modbus.c      **** void modbus_SendCommand(uint slaveID, tCommand c, u16 value) {
 648              		.loc 1 271 0
 649              		.cfi_startproc
 650              		@ args = 0, pretend = 0, frame = 0
 651              		@ frame_needed = 0, uses_anonymous_args = 0
 652              	.LVL86:
 653 0000 38B5     		push	{r3, r4, r5, lr}
 654              	.LCFI9:
 655              		.cfi_def_cfa_offset 16
 656              		.cfi_offset 3, -16
 657              		.cfi_offset 4, -12
 658              		.cfi_offset 5, -8
 659              		.cfi_offset 14, -4
 272:modbus.c      ****     if (waitResponse) return;
 660              		.loc 1 272 0
 661 0002 104C     		ldr	r4, .L79
 662 0004 2368     		ldr	r3, [r4]
 663 0006 DBB9     		cbnz	r3, .L69
 664              	.LVL87:
 665              	.LBB24:
 666              	.LBB25:
 273:modbus.c      **** 
 274:modbus.c      **** 	cmd = c;
 667              		.loc 1 274 0
 668 0008 0F4D     		ldr	r5, .L79+4
 275:modbus.c      ****     // APONTA QUAIS REGISTRADORES A ACESSAR NO DISPOSITIVO
 276:modbus.c      ****     // --------------------------------------------------------------------------------------------
 277:modbus.c      **** 
 278:modbus.c      ****     // Comando para ler os registradores: modelo, versão firmware e modo de operações dos reles
 279:modbus.c      ****     tcmd typeCMD = readREGS;
 280:modbus.c      ****     uint addrInit = 0;
 281:modbus.c      ****     uint nRegs = 3;
 282:modbus.c      **** 
 283:modbus.c      ****     // Comando para ler os valores dos sensores
 284:modbus.c      ****     if (cmd == cmdSET_TEMPERATURE_TYPE) {
 669              		.loc 1 284 0
 670 000a 0329     		cmp	r1, #3
 274:modbus.c      ****     // APONTA QUAIS REGISTRADORES A ACESSAR NO DISPOSITIVO
 671              		.loc 1 274 0
 672 000c 2970     		strb	r1, [r5]
 673              	.LVL88:
 674              		.loc 1 284 0
 675 000e 06D0     		beq	.L76
 285:modbus.c      ****         typeCMD = writeREG;
 286:modbus.c      ****         addrInit = 0x20;
 287:modbus.c      ****         nRegs = 1;
 288:modbus.c      **** 	}
 289:modbus.c      **** 	else if (cmd == cmdGET_TEMPERATURE) {
 676              		.loc 1 289 0
 677 0010 0229     		cmp	r1, #2
 678 0012 0ED0     		beq	.L77
 290:modbus.c      ****         addrInit = 0x200;
 291:modbus.c      ****         nRegs = 4;
 292:modbus.c      **** 	}
 293:modbus.c      **** 	else if (cmd == cmdRST_TEMPERATURE_STATISTIC) {
 679              		.loc 1 293 0
 680 0014 0429     		cmp	r1, #4
 681 0016 04D0     		beq	.L78
 281:modbus.c      **** 
 682              		.loc 1 281 0
 683 0018 0322     		movs	r2, #3
 684              	.LVL89:
 280:modbus.c      ****     uint nRegs = 3;
 685              		.loc 1 280 0
 686 001a 1946     		mov	r1, r3
 687              	.LVL90:
 688 001c 0CE0     		b	.L73
 689              	.LVL91:
 690              	.L76:
 286:modbus.c      ****         nRegs = 1;
 691              		.loc 1 286 0
 692 001e 2021     		movs	r1, #32
 693              	.LVL92:
 694 0020 01E0     		b	.L72
 695              	.LVL93:
 696              	.L78:
 294:modbus.c      ****         typeCMD = writeREG;
 295:modbus.c      ****         addrInit = 0xA001;
 697              		.loc 1 295 0
 698 0022 4AF20101 		movw	r1, #40961
 699              	.LVL94:
 700              	.L72:
 296:modbus.c      ****         nRegs = 1;
 297:modbus.c      **** 	}
 298:modbus.c      **** 
 299:modbus.c      **** 
 300:modbus.c      ****    	// ENVIA O COMANDO AO DISPOSITIVO ESCRAVO
 301:modbus.c      ****    	// --------------------------------------------------------------------------------------------
 302:modbus.c      ****    	int ret;
 303:modbus.c      ****     if (typeCMD == writeREG) {
 304:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 305:modbus.c      ****     	plognp("modbus WriteReg [slave %d] [reg 0x%x] [value 0x%x]"CMD_TERMINATOR, slaveID, addrInit, 
 306:modbus.c      ****     	#endif
 307:modbus.c      **** 		ret =  modbus_MasterWriteRegister(slaveID, addrInit, value);
 701              		.loc 1 307 0
 702 0026 FFF7FEFF 		bl	modbus_MasterWriteRegister
 703              	.LVL95:
 704              	.L75:
 308:modbus.c      **** 	} else if (typeCMD == writeREGS) {
 309:modbus.c      **** 	   	#if (LOG_MODBUS_MASTER == pdON)
 310:modbus.c      ****     	plognp("modbus WriteRegs [slave %d] [reg 0x%x] [len %d]"CMD_TERMINATOR, slaveID, addrInit, nRe
 311:modbus.c      ****     	#endif
 312:modbus.c      ****         ret = modbus_MasterWriteRegisters(slaveID, addrInit, nRegs, regs);
 313:modbus.c      ****     } else {
 314:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 315:modbus.c      ****     	plognp("modbus ReadRegs [slave %d] [reg 0x%x] [len %d]"CMD_TERMINATOR, slaveID, addrInit, nReg
 316:modbus.c      ****     	#endif
 317:modbus.c      **** 		ret = modbus_MasterReadRegisters(slaveID, addrInit, nRegs, regs);
 318:modbus.c      **** 	}
 319:modbus.c      **** 
 320:modbus.c      **** 	// se foi enviado com sucesso ficaremos na espera da resposta do termômetro
 321:modbus.c      **** 	if (ret == pdPASS) waitResponse = pdTRUE;
 705              		.loc 1 321 0
 706 002a 0128     		cmp	r0, #1
 707 002c 08D1     		bne	.L69
 708 002e 2060     		str	r0, [r4]
 709 0030 38BD     		pop	{r3, r4, r5, pc}
 710              	.LVL96:
 711              	.L77:
 291:modbus.c      **** 	}
 712              		.loc 1 291 0
 713 0032 0422     		movs	r2, #4
 714              	.LVL97:
 290:modbus.c      ****         nRegs = 4;
 715              		.loc 1 290 0
 716 0034 4FF40071 		mov	r1, #512
 717              	.LVL98:
 718              	.L73:
 317:modbus.c      **** 	}
 719              		.loc 1 317 0
 720 0038 044B     		ldr	r3, .L79+8
 721 003a FFF7FEFF 		bl	modbus_MasterReadRegisters
 722              	.LVL99:
 723 003e F4E7     		b	.L75
 724              	.LVL100:
 725              	.L69:
 726 0040 38BD     		pop	{r3, r4, r5, pc}
 727              	.L80:
 728 0042 00BF     		.align	2
 729              	.L79:
 730 0044 00000000 		.word	.LANCHOR0
 731 0048 00000000 		.word	.LANCHOR1
 732 004c 00000000 		.word	.LANCHOR2
 733              	.LBE25:
 734              	.LBE24:
 735              		.cfi_endproc
 736              	.LFE8:
 738              		.section	.text.modbus_Tick,"ax",%progbits
 739              		.align	1
 740              		.global	modbus_Tick
 741              		.thumb
 742              		.thumb_func
 744              	modbus_Tick:
 745              	.LFB9:
 322:modbus.c      **** 
 323:modbus.c      **** 	#if (LOG_MODBUS_MASTER == pdON)
 324:modbus.c      **** 	else plognp("modbus err[%d] send querie"CMD_TERMINATOR, modbus_MasterReadStatus());
 325:modbus.c      ****     #endif
 326:modbus.c      **** }
 327:modbus.c      **** 
 328:modbus.c      **** 
 329:modbus.c      **** void modbus_Tick(void) {
 746              		.loc 1 329 0
 747              		.cfi_startproc
 748              		@ args = 0, pretend = 0, frame = 0
 749              		@ frame_needed = 0, uses_anonymous_args = 0
 750 0000 08B5     		push	{r3, lr}
 751              	.LCFI10:
 752              		.cfi_def_cfa_offset 8
 753              		.cfi_offset 3, -8
 754              		.cfi_offset 14, -4
 330:modbus.c      **** 	modbus_MasterTick();
 755              		.loc 1 330 0
 756 0002 FFF7FEFF 		bl	modbus_MasterTick
 757              	.LVL101:
 331:modbus.c      **** 	modbus_SlaveTick();
 332:modbus.c      **** }
 758              		.loc 1 332 0
 759 0006 BDE80840 		pop	{r3, lr}
 760              	.LCFI11:
 761              		.cfi_restore 14
 762              		.cfi_restore 3
 763              		.cfi_def_cfa_offset 0
 331:modbus.c      **** 	modbus_SlaveTick();
 764              		.loc 1 331 0
 765 000a FFF7FEBF 		b	modbus_SlaveTick
 766              	.LVL102:
 767              		.cfi_endproc
 768              	.LFE9:
 770              		.section	.text.modbus_Process,"ax",%progbits
 771              		.align	1
 772              		.global	modbus_Process
 773              		.thumb
 774              		.thumb_func
 776              	modbus_Process:
 777              	.LFB10:
 333:modbus.c      **** 
 334:modbus.c      **** static uint thermometerAccess = 1;
 335:modbus.c      **** static uint triggerAction = 0;
 336:modbus.c      **** 
 337:modbus.c      **** void modbus_Process(void) {
 778              		.loc 1 337 0
 779              		.cfi_startproc
 780              		@ args = 0, pretend = 0, frame = 0
 781              		@ frame_needed = 0, uses_anonymous_args = 0
 782 0000 70B5     		push	{r4, r5, r6, lr}
 783              	.LCFI12:
 784              		.cfi_def_cfa_offset 16
 785              		.cfi_offset 4, -16
 786              		.cfi_offset 5, -12
 787              		.cfi_offset 6, -8
 788              		.cfi_offset 14, -4
 338:modbus.c      **** 	modbus_SlaveProcess();
 339:modbus.c      **** 	modbus_MasterProcess();
 340:modbus.c      **** 
 341:modbus.c      **** 	// se não estamos esperando a resposta do modbus_SendCommand anterior vamos analisar o próximo com
 342:modbus.c      **** 	if (!waitResponse) {
 789              		.loc 1 342 0
 790 0002 564C     		ldr	r4, .L109
 338:modbus.c      **** 	modbus_SlaveProcess();
 791              		.loc 1 338 0
 792 0004 FFF7FEFF 		bl	modbus_SlaveProcess
 793              	.LVL103:
 339:modbus.c      **** 
 794              		.loc 1 339 0
 795 0008 FFF7FEFF 		bl	modbus_MasterProcess
 796              	.LVL104:
 797              		.loc 1 342 0
 798 000c 2268     		ldr	r2, [r4]
 799 000e 002A     		cmp	r2, #0
 800 0010 4BD1     		bne	.L83
 801              	.LVL105:
 802              	.LBB26:
 343:modbus.c      **** 		tCommand cmdSend;
 344:modbus.c      **** 		u16 value = 0;
 345:modbus.c      **** 		int cmdConfig;
 346:modbus.c      **** 		if ( (control.setTempType) || (control.setTempStatics)) cmdConfig = pdTRUE; else cmdConfig = pdFA
 803              		.loc 1 346 0
 804 0012 534C     		ldr	r4, .L109+4
 347:modbus.c      **** 
 348:modbus.c      **** 		// aponta para o próximo termômetro
 349:modbus.c      **** 		if (thermometerAccess >= nTHERMOMETER) { // se chegamos no último termômetro vamos apontar para o
 805              		.loc 1 349 0
 806 0014 534D     		ldr	r5, .L109+8
 346:modbus.c      **** 
 807              		.loc 1 346 0
 808 0016 2378     		ldrb	r3, [r4]	@ zero_extendqisi2
 809              		.loc 1 349 0
 810 0018 2868     		ldr	r0, [r5]
 346:modbus.c      **** 
 811              		.loc 1 346 0
 812 001a 03F00606 		and	r6, r3, #6
 813              	.LVL106:
 814 001e 0121     		movs	r1, #1
 815              		.loc 1 349 0
 816 0020 90B1     		cbz	r0, .L84
 350:modbus.c      **** 			thermometerAccess = 1;
 817              		.loc 1 350 0
 818 0022 2960     		str	r1, [r5]
 351:modbus.c      **** 
 352:modbus.c      **** 			// se foi algum comando de config dos termômetros vamos sinalizar que não tem mais configurações
 353:modbus.c      **** 			if ( cmdConfig ) {
 819              		.loc 1 353 0
 820 0024 46B1     		cbz	r6, .L85
 354:modbus.c      **** 				control.action = pdFALSE;
 821              		.loc 1 354 0
 822 0026 62F30003 		bfi	r3, r2, #0, #1
 823 002a 2370     		strb	r3, [r4]
 355:modbus.c      **** 				triggerAction = pdFALSE;
 824              		.loc 1 355 0
 825 002c 4E4B     		ldr	r3, .L109+12
 356:modbus.c      **** 				#if (LOG_APP == pdON)
 357:modbus.c      **** 				plognp("Finish config"CMD_TERMINATOR);
 826              		.loc 1 357 0
 827 002e 4F49     		ldr	r1, .L109+16
 828 0030 0220     		movs	r0, #2
 355:modbus.c      **** 				triggerAction = pdFALSE;
 829              		.loc 1 355 0
 830 0032 1A60     		str	r2, [r3]
 831              		.loc 1 357 0
 832 0034 FFF7FEFF 		bl	rprintf
 833              	.LVL107:
 834              	.L85:
 358:modbus.c      **** 				#endif
 359:modbus.c      **** 			}
 360:modbus.c      **** 			control.setTempType = pdFALSE;
 835              		.loc 1 360 0
 836 0038 2378     		ldrb	r3, [r4]	@ zero_extendqisi2
 361:modbus.c      **** 			control.setTempStatics = pdFALSE;
 362:modbus.c      **** 			cmdConfig = pdFALSE;
 837              		.loc 1 362 0
 838 003a 0026     		movs	r6, #0
 839              	.LVL108:
 361:modbus.c      **** 			control.setTempStatics = pdFALSE;
 840              		.loc 1 361 0
 841 003c 03F0FB03 		and	r3, r3, #251
 842 0040 6FF34103 		bfc	r3, #1, #1
 843 0044 2370     		strb	r3, [r4]
 844              	.LVL109:
 845 0046 03E0     		b	.L86
 846              	.LVL110:
 847              	.L84:
 346:modbus.c      **** 
 848              		.loc 1 346 0
 849 0048 0036     		adds	r6, r6, #0
 850 004a 18BF     		it	ne
 851 004c 0126     		movne	r6, #1
 852              	.LVL111:
 363:modbus.c      **** 		} else thermometerAccess++;
 853              		.loc 1 363 0
 854 004e 2960     		str	r1, [r5]
 855              	.LVL112:
 856              	.L86:
 364:modbus.c      **** 
 365:modbus.c      **** 		// verifica se foi emitido algum comando para configuração dos termômetros
 366:modbus.c      **** 		if ( (control.action == pdTRUE) && (triggerAction != control.action) && (cmdConfig) ) { // se é p
 857              		.loc 1 366 0
 858 0050 2378     		ldrb	r3, [r4]	@ zero_extendqisi2
 859 0052 DA07     		lsls	r2, r3, #31
 860 0054 0DD5     		bpl	.L87
 861              		.loc 1 366 0 is_stmt 0 discriminator 1
 862 0056 444A     		ldr	r2, .L109+12
 863 0058 03F00103 		and	r3, r3, #1
 864 005c 1168     		ldr	r1, [r2]
 865 005e 8B42     		cmp	r3, r1
 866 0060 07D0     		beq	.L87
 867              		.loc 1 366 0 discriminator 2
 868 0062 36B1     		cbz	r6, .L87
 367:modbus.c      **** 			thermometerAccess = 1; // aponta para o primeiro termômetro
 869              		.loc 1 367 0 is_stmt 1
 870 0064 0121     		movs	r1, #1
 871 0066 2960     		str	r1, [r5]
 368:modbus.c      **** 			triggerAction = control.action;
 369:modbus.c      **** 			#if (LOG_APP == pdON)
 370:modbus.c      **** 			plognp("Init config"CMD_TERMINATOR);
 872              		.loc 1 370 0
 873 0068 0220     		movs	r0, #2
 874 006a 4149     		ldr	r1, .L109+20
 368:modbus.c      **** 			triggerAction = control.action;
 875              		.loc 1 368 0
 876 006c 1360     		str	r3, [r2]
 877              		.loc 1 370 0
 878 006e FFF7FEFF 		bl	rprintf
 879              	.LVL113:
 880              	.L87:
 371:modbus.c      **** 			#endif
 372:modbus.c      **** 		}
 373:modbus.c      **** 
 374:modbus.c      **** 		if (control.setTempType) {
 881              		.loc 1 374 0
 882 0072 2378     		ldrb	r3, [r4]	@ zero_extendqisi2
 883 0074 03F00401 		and	r1, r3, #4
 884 0078 01F0FF02 		and	r2, r1, #255
 885 007c 19B1     		cbz	r1, .L88
 886              	.LVL114:
 375:modbus.c      **** 			cmdSend = cmdSET_TEMPERATURE_TYPE;
 376:modbus.c      **** 			value = control.tempType;
 887              		.loc 1 376 0
 888 007e 384B     		ldr	r3, .L109+4
 375:modbus.c      **** 			cmdSend = cmdSET_TEMPERATURE_TYPE;
 889              		.loc 1 375 0
 890 0080 0321     		movs	r1, #3
 891              		.loc 1 376 0
 892 0082 9A88     		ldrh	r2, [r3, #4]
 893              	.LVL115:
 894 0084 04E0     		b	.L89
 895              	.LVL116:
 896              	.L88:
 344:modbus.c      **** 		int cmdConfig;
 897              		.loc 1 344 0
 898 0086 13F0020F 		tst	r3, #2
 899 008a 14BF     		ite	ne
 900 008c 0421     		movne	r1, #4
 901 008e 0221     		moveq	r1, #2
 902              	.LVL117:
 903              	.L89:
 377:modbus.c      **** 		} else if (control.setTempStatics)
 378:modbus.c      **** 				cmdSend = cmdRST_TEMPERATURE_STATISTIC;
 379:modbus.c      **** 		else	cmdSend = cmdGET_TEMPERATURE;
 380:modbus.c      **** 
 381:modbus.c      **** 		modbus_SendCommand(thermometerAccess, cmdSend, value);
 904              		.loc 1 381 0
 905 0090 2868     		ldr	r0, [r5]
 906 0092 FFF7FEFF 		bl	modbus_SendCommand
 907              	.LVL118:
 382:modbus.c      **** 
 383:modbus.c      **** 		#if (LOG_APP == pdON)
 384:modbus.c      **** 		if ( cmdConfig ) plognp("Send Command to thermometer %d"CMD_TERMINATOR, thermometerAccess);
 908              		.loc 1 384 0
 909 0096 002E     		cmp	r6, #0
 910 0098 5ED0     		beq	.L82
 911              	.LBE26:
 385:modbus.c      **** 		#endif
 386:modbus.c      **** 
 387:modbus.c      **** 		return;
 388:modbus.c      **** 	}
 389:modbus.c      **** 
 390:modbus.c      **** 	int ret = modbus_MasterReadStatus();
 391:modbus.c      **** 	//	BUSY: Ficar na espera da resposta
 392:modbus.c      **** 	//  ERROR: Notificar um erro, e tomar o procedimento cabível
 393:modbus.c      **** 	//  OK para escrita: Fazer nada, pois os valores dos registradores foram salvos no escravo com suc
 394:modbus.c      **** 	//	OK para Leitura: Capturar os valores dos registradores lidos do escravo
 395:modbus.c      **** 
 396:modbus.c      **** 	// se ainda está ocupado não faz nada
 397:modbus.c      **** 	if (ret == errMODBUS_BUSY) return;
 398:modbus.c      **** 	waitResponse = pdFALSE;
 399:modbus.c      **** 	// se for algum erro
 400:modbus.c      **** 	if (ret < 0) {
 401:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 402:modbus.c      ****     	plognp("modbus err[%d] wait response "CMD_TERMINATOR, ret);
 403:modbus.c      **** 		#endif
 404:modbus.c      **** 		if (cmd == cmdGET_TEMPERATURE) {
 405:modbus.c      **** 			if (ret == errMODBUS_EXCEPTION)
 406:modbus.c      **** 		 		control.thermometer[thermometerAccess-1].stsCom = modbus_MasterReadException();
 407:modbus.c      **** 					// modbusILLEGAL_FUNCTION: O termômetro recebeu uma função que não foi implementada ou não foi
 408:modbus.c      **** 					// modbusILLEGAL_DATA_ADDRESS: O termômetro precisou acessar um endereço inexistente.
 409:modbus.c      **** 					// modbusILLEGAL_DATA_VALUE: O valor contido no campo de dado não é permitido pelo termômetro.
 410:modbus.c      **** 					// modbusSLAVE_DEVICE_FAILURE: Um irrecuperável erro ocorreu enquanto o termômetro estava tent
 411:modbus.c      **** 			else control.thermometer[thermometerAccess-1].stsCom = 0; // sinaliza que não há comunicação com
 412:modbus.c      **** 		}
 413:modbus.c      **** 		return;
 414:modbus.c      **** 	}
 415:modbus.c      **** 
 416:modbus.c      ****     // ATUALIZA VARS COM A LEITURA
 417:modbus.c      ****     // --------------------------------------------------------------------------------------------
 418:modbus.c      **** 
 419:modbus.c      **** 	#if (LOG_MODBUS_MASTER == pdON)
 420:modbus.c      ****    	plognp("Response thermometer %d"CMD_TERMINATOR, thermometerAccess);
 421:modbus.c      ****    	#endif
 422:modbus.c      **** 
 423:modbus.c      ****     // Comando para ler os registradores: modelo e versão firmware
 424:modbus.c      ****     if (cmd == cmdGET_INFO) {
 425:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 426:modbus.c      ****     	plognp("model %c%c%c%c"CMD_TERMINATOR, (regs[0] & 0xff), (regs[0] >> 8), (regs[1] & 0xff), (re
 427:modbus.c      ****     	plognp("firmware %c.%c"CMD_TERMINATOR, (regs[2] & 0xff), (regs[2] >> 8));
 428:modbus.c      ****     	#endif
 429:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[0] = (regs[0] & 0xff);
 430:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[1] = (regs[0] >> 8);
 431:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[2] = (regs[1] & 0xff);
 432:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[3] = (regs[1] >> 8);
 433:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[4] = 0;
 434:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[0] = (regs[2] & 0xff);
 435:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[1] = (regs[2] >> 8);
 436:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[2] = 0;
 437:modbus.c      **** 
 438:modbus.c      **** 	// Comando para ler o termômetro
 439:modbus.c      ****     } else if (cmd == cmdGET_TEMPERATURE) {
 440:modbus.c      **** 		control.thermometer[thermometerAccess-1].stsCom = 5; // sinaliza que a conexão fou feita com suce
 441:modbus.c      **** 		control.thermometer[thermometerAccess-1].sts =  regs[0] & 0x1f;
 442:modbus.c      **** 		control.thermometer[thermometerAccess-1].value = regs[1];
 443:modbus.c      **** 		control.thermometer[thermometerAccess-1].valueMin = regs[2];
 444:modbus.c      **** 		control.thermometer[thermometerAccess-1].valueMax = regs[3];
 445:modbus.c      **** 	}
 446:modbus.c      **** }
 912              		.loc 1 446 0 discriminator 1
 913 009a BDE87040 		pop	{r4, r5, r6, lr}
 914              	.LCFI13:
 915              		.cfi_remember_state
 916              		.cfi_restore 14
 917              		.cfi_restore 6
 918              		.cfi_restore 5
 919              		.cfi_restore 4
 920              		.cfi_def_cfa_offset 0
 921              	.LVL119:
 922              	.LBB27:
 384:modbus.c      **** 		#endif
 923              		.loc 1 384 0 discriminator 1
 924 009e 314B     		ldr	r3, .L109+8
 925 00a0 3449     		ldr	r1, .L109+24
 926 00a2 1A68     		ldr	r2, [r3]
 927 00a4 0220     		movs	r0, #2
 928 00a6 FFF7FEBF 		b	rprintf
 929              	.LVL120:
 930              	.L83:
 931              	.LCFI14:
 932              		.cfi_restore_state
 933              	.LBE27:
 390:modbus.c      **** 	//	BUSY: Ficar na espera da resposta
 934              		.loc 1 390 0
 935 00aa FFF7FEFF 		bl	modbus_MasterReadStatus
 936              	.LVL121:
 397:modbus.c      **** 	waitResponse = pdFALSE;
 937              		.loc 1 397 0
 938 00ae 10F1860F 		cmn	r0, #134
 939 00b2 51D0     		beq	.L82
 398:modbus.c      **** 	// se for algum erro
 940              		.loc 1 398 0
 941 00b4 0021     		movs	r1, #0
 942 00b6 304B     		ldr	r3, .L109+28
 400:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 943              		.loc 1 400 0
 944 00b8 8842     		cmp	r0, r1
 398:modbus.c      **** 	// se for algum erro
 945              		.loc 1 398 0
 946 00ba 2160     		str	r1, [r4]
 404:modbus.c      **** 			if (ret == errMODBUS_EXCEPTION)
 947              		.loc 1 404 0
 948 00bc 1B78     		ldrb	r3, [r3]	@ zero_extendqisi2
 400:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 949              		.loc 1 400 0
 950 00be 14DA     		bge	.L93
 404:modbus.c      **** 			if (ret == errMODBUS_EXCEPTION)
 951              		.loc 1 404 0
 952 00c0 022B     		cmp	r3, #2
 953 00c2 49D1     		bne	.L82
 954 00c4 274B     		ldr	r3, .L109+8
 405:modbus.c      **** 		 		control.thermometer[thermometerAccess-1].stsCom = modbus_MasterReadException();
 955              		.loc 1 405 0
 956 00c6 8230     		adds	r0, r0, #130
 957              	.LVL122:
 958 00c8 254D     		ldr	r5, .L109+4
 406:modbus.c      **** 					// modbusILLEGAL_FUNCTION: O termômetro recebeu uma função que não foi implementada ou não foi
 959              		.loc 1 406 0
 960 00ca 1A68     		ldr	r2, [r3]
 405:modbus.c      **** 		 		control.thermometer[thermometerAccess-1].stsCom = modbus_MasterReadException();
 961              		.loc 1 405 0
 962 00cc 07D1     		bne	.L94
 406:modbus.c      **** 					// modbusILLEGAL_FUNCTION: O termômetro recebeu uma função que não foi implementada ou não foi
 963              		.loc 1 406 0
 964 00ce 541E     		subs	r4, r2, #1
 965 00d0 FFF7FEFF 		bl	modbus_MasterReadException
 966              	.LVL123:
 967 00d4 1C23     		movs	r3, #28
 968 00d6 03FB0454 		mla	r4, r3, r4, r5
 969 00da 2062     		str	r0, [r4, #32]
 970 00dc 70BD     		pop	{r4, r5, r6, pc}
 971              	.LVL124:
 972              	.L94:
 411:modbus.c      **** 		}
 973              		.loc 1 411 0
 974 00de 013A     		subs	r2, r2, #1
 975 00e0 1C23     		movs	r3, #28
 976 00e2 03FB0253 		mla	r3, r3, r2, r5
 977 00e6 1962     		str	r1, [r3, #32]
 978 00e8 70BD     		pop	{r4, r5, r6, pc}
 979              	.LVL125:
 980              	.L93:
 424:modbus.c      ****     	#if (LOG_MODBUS_MASTER == pdON)
 981              		.loc 1 424 0
 982 00ea 012B     		cmp	r3, #1
 983 00ec 1ED1     		bne	.L95
 429:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[1] = (regs[0] >> 8);
 984              		.loc 1 429 0
 985 00ee 1D4B     		ldr	r3, .L109+8
 986 00f0 1C25     		movs	r5, #28
 987 00f2 1B68     		ldr	r3, [r3]
 988 00f4 214C     		ldr	r4, .L109+32
 989 00f6 5A1E     		subs	r2, r3, #1
 990 00f8 194B     		ldr	r3, .L109+4
 991 00fa 2088     		ldrh	r0, [r4]
 992              	.LVL126:
 993 00fc 05FB0233 		mla	r3, r5, r2, r3
 431:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[3] = (regs[1] >> 8);
 994              		.loc 1 431 0
 995 0100 6288     		ldrh	r2, [r4, #2]
 429:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[1] = (regs[0] >> 8);
 996              		.loc 1 429 0
 997 0102 83F83400 		strb	r0, [r3, #52]
 431:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[3] = (regs[1] >> 8);
 998              		.loc 1 431 0
 999 0106 83F83620 		strb	r2, [r3, #54]
 432:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[4] = 0;
 1000              		.loc 1 432 0
 1001 010a 120A     		lsrs	r2, r2, #8
 1002 010c 83F83720 		strb	r2, [r3, #55]
 434:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[1] = (regs[2] >> 8);
 1003              		.loc 1 434 0
 1004 0110 A288     		ldrh	r2, [r4, #4]
 430:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[2] = (regs[1] & 0xff);
 1005              		.loc 1 430 0
 1006 0112 000A     		lsrs	r0, r0, #8
 434:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[1] = (regs[2] >> 8);
 1007              		.loc 1 434 0
 1008 0114 83F83920 		strb	r2, [r3, #57]
 435:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[2] = 0;
 1009              		.loc 1 435 0
 1010 0118 120A     		lsrs	r2, r2, #8
 430:modbus.c      ****     	control.thermometer[thermometerAccess-1].model[2] = (regs[1] & 0xff);
 1011              		.loc 1 430 0
 1012 011a 83F83500 		strb	r0, [r3, #53]
 433:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[0] = (regs[2] & 0xff);
 1013              		.loc 1 433 0
 1014 011e 83F83810 		strb	r1, [r3, #56]
 435:modbus.c      ****     	control.thermometer[thermometerAccess-1].firmware[2] = 0;
 1015              		.loc 1 435 0
 1016 0122 83F83A20 		strb	r2, [r3, #58]
 436:modbus.c      **** 
 1017              		.loc 1 436 0
 1018 0126 83F83B10 		strb	r1, [r3, #59]
 1019 012a 70BD     		pop	{r4, r5, r6, pc}
 1020              	.LVL127:
 1021              	.L95:
 439:modbus.c      **** 		control.thermometer[thermometerAccess-1].stsCom = 5; // sinaliza que a conexão fou feita com suce
 1022              		.loc 1 439 0
 1023 012c 022B     		cmp	r3, #2
 1024 012e 13D1     		bne	.L82
 440:modbus.c      **** 		control.thermometer[thermometerAccess-1].sts =  regs[0] & 0x1f;
 1025              		.loc 1 440 0
 1026 0130 0C4B     		ldr	r3, .L109+8
 1027 0132 1C21     		movs	r1, #28
 1028 0134 1B68     		ldr	r3, [r3]
 1029 0136 5A1E     		subs	r2, r3, #1
 1030 0138 094B     		ldr	r3, .L109+4
 1031 013a 01FB0233 		mla	r3, r1, r2, r3
 1032 013e 0522     		movs	r2, #5
 1033 0140 1A62     		str	r2, [r3, #32]
 441:modbus.c      **** 		control.thermometer[thermometerAccess-1].value = regs[1];
 1034              		.loc 1 441 0
 1035 0142 0E4A     		ldr	r2, .L109+32
 1036 0144 1188     		ldrh	r1, [r2]
 1037 0146 01F01F01 		and	r1, r1, #31
 1038 014a 9984     		strh	r1, [r3, #36]	@ movhi
 442:modbus.c      **** 		control.thermometer[thermometerAccess-1].valueMin = regs[2];
 1039              		.loc 1 442 0
 1040 014c 5188     		ldrh	r1, [r2, #2]
 1041 014e 9962     		str	r1, [r3, #40]
 443:modbus.c      **** 		control.thermometer[thermometerAccess-1].valueMax = regs[3];
 1042              		.loc 1 443 0
 1043 0150 9188     		ldrh	r1, [r2, #4]
 444:modbus.c      **** 	}
 1044              		.loc 1 444 0
 1045 0152 D288     		ldrh	r2, [r2, #6]
 443:modbus.c      **** 		control.thermometer[thermometerAccess-1].valueMax = regs[3];
 1046              		.loc 1 443 0
 1047 0154 D962     		str	r1, [r3, #44]
 444:modbus.c      **** 	}
 1048              		.loc 1 444 0
 1049 0156 1A63     		str	r2, [r3, #48]
 1050              	.LVL128:
 1051              	.L82:
 1052 0158 70BD     		pop	{r4, r5, r6, pc}
 1053              	.L110:
 1054 015a 00BF     		.align	2
 1055              	.L109:
 1056 015c 00000000 		.word	.LANCHOR0
 1057 0160 00000000 		.word	control
 1058 0164 00000000 		.word	.LANCHOR3
 1059 0168 00000000 		.word	.LANCHOR4
 1060 016c 00000000 		.word	.LC0
 1061 0170 0F000000 		.word	.LC1
 1062 0174 1C000000 		.word	.LC2
 1063 0178 00000000 		.word	.LANCHOR1
 1064 017c 00000000 		.word	.LANCHOR2
 1065              		.cfi_endproc
 1066              	.LFE10:
 1068              		.comm	control,60,4
 1069              		.section	.bss.cmd,"aw",%nobits
 1070              		.set	.LANCHOR1,. + 0
 1073              	cmd:
 1074 0000 00       		.space	1
 1075              		.section	.bss.waitResponse,"aw",%nobits
 1076              		.align	2
 1077              		.set	.LANCHOR0,. + 0
 1080              	waitResponse:
 1081 0000 00000000 		.space	4
 1082              		.section	.bss.triggerAction,"aw",%nobits
 1083              		.align	2
 1084              		.set	.LANCHOR4,. + 0
 1087              	triggerAction:
 1088 0000 00000000 		.space	4
 1089              		.section	.rodata.str1.1,"aMS",%progbits,1
 1090              	.LC0:
 1091 0000 46696E69 		.ascii	"Finish config\012\000"
 1091      73682063 
 1091      6F6E6669 
 1091      670A00
 1092              	.LC1:
 1093 000f 496E6974 		.ascii	"Init config\012\000"
 1093      20636F6E 
 1093      6669670A 
 1093      00
 1094              	.LC2:
 1095 001c 53656E64 		.ascii	"Send Command to thermometer %d\012\000"
 1095      20436F6D 
 1095      6D616E64 
 1095      20746F20 
 1095      74686572 
 1096              		.section	.data.thermometerAccess,"aw",%progbits
 1097              		.align	2
 1098              		.set	.LANCHOR3,. + 0
 1101              	thermometerAccess:
 1102 0000 01000000 		.word	1
 1103              		.section	.bss.regs,"aw",%nobits
 1104              		.align	1
 1105              		.set	.LANCHOR2,. + 0
 1108              	regs:
 1109 0000 00000000 		.space	240
 1109      00000000 
 1109      00000000 
 1109      00000000 
 1109      00000000 
 1110              		.text
 1111              	.Letext0:
 1112              		.file 2 "uc_libc_dev/_libdef/uc_libdefs.h"
 1113              		.file 3 "app.h"
 1114              		.file 4 "uc_libc_dev/_arch/arm_lpc/uart/uart1_irq.h"
 1115              		.file 5 "uc_libc_dev/_arch/arm_lpc/uart/uart3_irq.h"
 1116              		.file 6 "uc_libc_dev/protocol/modbus/modbus_slave.h"
 1117              		.file 7 "uc_libc_dev/protocol/modbus/modbus_master.h"
 1118              		.file 8 "uc_libc_dev/stdio/stdio_uc.h"
DEFINED SYMBOLS
                            *ABS*:00000000 modbus.c
D:\_temp\_windows\cc5tqPZJ.s:20     .text.master_PutString:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:24     .text.master_PutString:00000000 master_PutString
D:\_temp\_windows\cc5tqPZJ.s:65     .text.master_PutString:00000024 $d
D:\_temp\_windows\cc5tqPZJ.s:71     .text.slave_PutString:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:75     .text.slave_PutString:00000000 slave_PutString
D:\_temp\_windows\cc5tqPZJ.s:115    .text.slave_PutString:00000024 $d
D:\_temp\_windows\cc5tqPZJ.s:121    .text.slave_ReadRegisters:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:125    .text.slave_ReadRegisters:00000000 slave_ReadRegisters
D:\_temp\_windows\cc5tqPZJ.s:314    .text.slave_ReadRegisters:000000e0 $d
                            *COM*:0000003c control
D:\_temp\_windows\cc5tqPZJ.s:319    .text.slave_SetValue:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:323    .text.slave_SetValue:00000000 slave_SetValue
D:\_temp\_windows\cc5tqPZJ.s:400    .text.slave_SetValue:00000040 $d
D:\_temp\_windows\cc5tqPZJ.s:405    .text.slave_WriteRegister:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:409    .text.slave_WriteRegister:00000000 slave_WriteRegister
D:\_temp\_windows\cc5tqPZJ.s:455    .text.slave_WriteRegisters:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:459    .text.slave_WriteRegisters:00000000 slave_WriteRegisters
D:\_temp\_windows\cc5tqPZJ.s:539    .text.modbus_Init:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:544    .text.modbus_Init:00000000 modbus_Init
D:\_temp\_windows\cc5tqPZJ.s:625    .text.modbus_Init:00000064 $d
D:\_temp\_windows\cc5tqPZJ.s:641    .text.modbus_SendCommand:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:646    .text.modbus_SendCommand:00000000 modbus_SendCommand
D:\_temp\_windows\cc5tqPZJ.s:730    .text.modbus_SendCommand:00000044 $d
D:\_temp\_windows\cc5tqPZJ.s:739    .text.modbus_Tick:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:744    .text.modbus_Tick:00000000 modbus_Tick
D:\_temp\_windows\cc5tqPZJ.s:771    .text.modbus_Process:00000000 $t
D:\_temp\_windows\cc5tqPZJ.s:776    .text.modbus_Process:00000000 modbus_Process
D:\_temp\_windows\cc5tqPZJ.s:1056   .text.modbus_Process:0000015c $d
D:\_temp\_windows\cc5tqPZJ.s:1073   .bss.cmd:00000000 cmd
D:\_temp\_windows\cc5tqPZJ.s:1074   .bss.cmd:00000000 $d
D:\_temp\_windows\cc5tqPZJ.s:1076   .bss.waitResponse:00000000 $d
D:\_temp\_windows\cc5tqPZJ.s:1080   .bss.waitResponse:00000000 waitResponse
D:\_temp\_windows\cc5tqPZJ.s:1083   .bss.triggerAction:00000000 $d
D:\_temp\_windows\cc5tqPZJ.s:1087   .bss.triggerAction:00000000 triggerAction
D:\_temp\_windows\cc5tqPZJ.s:1097   .data.thermometerAccess:00000000 $d
D:\_temp\_windows\cc5tqPZJ.s:1101   .data.thermometerAccess:00000000 thermometerAccess
D:\_temp\_windows\cc5tqPZJ.s:1104   .bss.regs:00000000 $d
D:\_temp\_windows\cc5tqPZJ.s:1108   .bss.regs:00000000 regs
                     .debug_frame:00000010 $d

UNDEFINED SYMBOLS
uart1_WriteTx
uart1_EmptyTx
uart3_WriteTx
uart3_EmptyTx
temp_SetType
temp_InitStatistic
modbus_SlaveInit
modbus_SlaveAppendFunctions
uart3_Init
modbus_MasterInit
modbus_MasterTimeout
uart1_Init
uart3_ClearBufferRx
uart3_GetChar
uart3_BufferQtdRx
uart1_ClearBufferRx
uart1_GetChar
modbus_MasterWriteRegister
modbus_MasterReadRegisters
modbus_MasterTick
modbus_SlaveTick
modbus_SlaveProcess
modbus_MasterProcess
rprintf
modbus_MasterReadStatus
modbus_MasterReadException
